<?php $app = $_POST['app']; ?>

	
			

<?php if ($ajax == 'views'): ?>
	$post_id = get_the_ID();
	$views = get_post_meta($post_id, 'views', true);
	if ($views == '') {
		add_post_meta($post_id, 'views', 1, true);
	} else {
		$views = (int) $views;
		update_post_meta($post_id, 'views', ($views+1));
	} 
<?php else:?>
<?php get_header(); ?>

	
			<?php /* Start the post */?>
		<?php if ( have_posts() ) : the_post(); ?>
			<div id="content" role="main">
				<div id="posts">
					
					<?php 
						$post_id = get_the_ID();
						$views = get_post_meta($post_id, 'views', true);
						if ($views == '') {
							add_post_meta($post_id, 'views', 1, true);
							$views = 1;
						} 
						
						$idObj = get_category_by_slug('zone');
						$id = $idObj->term_id;
						
						$pcate = get_the_category();
						$args=array(
							'child_of' => $id
						);
						$ccate=get_categories($args);
						$rcat = false;
						if($pcate && $ccate){
							foreach($pcate as $pcat) {
								foreach($ccate as $ccat) {
									if ($pcat->term_id == $ccat->term_id) {
										$rcat = $pcat;
									}
								}
								if ($rcat) {
									break;
								}
							}
						}
						
						
						
					?>
						<article class="post" id="post-<?php echo $post_id; ?>" views="<?php echo $views;?>">
							<h1 class="title"><? the_title(); ?></h1>
							<?php edit_post_link();?>
							<div class="body">
							<? 
								if ($rcat) {
									echo '<div class="'.$rcat->slug.'">';
								}
								the_content(); 
								if ($rcat) {
									echo '</div>';
								}	
							?>
							</div>
							
						</article>
					
					<div class="clear"></div>
					
				</div>
			</div><!-- #content -->
			<div class="clear"></div>
			<div class="apps">
			<?php get_footer('addthis'); ?>
			<div class="clear"></div>
			</div>
			<div class="clear"></div>
			<div class="related-post">
			</div>
		
			
			<?php comments_template( '', true ); ?>
			
			
		<?php endif; ?>
				
		
<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/single.js"></script>
<?php get_footer(); ?>
<?php endif;?>